API Documentation
Environment.h
1 // Environment.h
3 //
5 
6 namespace nkScripts
7 {
13  class DLL_SCRIPTS_EXPORT Environment final
14  {
15  public :
16 
25 
26  // Getters
34  const char* getName () const ;
35 
36  // Setters
42  void setEnvironmentFor (INTERPRETER interpretType) ;
50  void setName (const char* name) ;
51 
52  // Execution
59  bool execute (const Script& script) ;
64 
65  // Manipulating memory
72  void setVar (const char* name, bool value) ;
79  void setVar (const char* name, int value) ;
86  void setVar (const char* name, float value) ;
93  void setVar (const char* name, double value) ;
100  void setVar (const char* name, const char* value) ;
107  void setVar (const char* name, const ScriptObjectReference& value) ;
115  void setObject (const char* name, const char* userTypeName, void* value) ;
116 
122  bool isVarSet (const char* name) ;
123 
131  bool getVar (const char* name, bool defaultValue) ;
139  int getVar (const char* name, int defaultValue) ;
147  float getVar (const char* name, float defaultValue) ;
155  double getVar (const char* name, double defaultValue) ;
163  const char* getVar (const char* name, const char* defaultValue) ;
170  ScriptObjectReference getVar (const char* name) ;
180  void* getObject (const char* name, const char* userTypeName = nullptr) ;
188 
197  Function* setFunc (const char* name) ;
204  bool isFuncSet (const char* name) ;
209  Function* getFunc (const char* name) ;
210 
219  UserType* setUserType (const char* name) ;
226  bool isUserTypeSet (const char* name) ;
231  UserType* getUserType (const char* name) ;
232 
240  Namespace* setNamespace (const char* name) ;
247  bool isNamespaceSet (const char* name) ;
252  Namespace* getNamespace (const char* name) ;
253 
254  // Call C++ -> Script
263  bool callScriptFunction (const ScriptObjectReference& reference, const DataStack& args, DataStack& expectedOutput) ;
264 
274  std::vector<unsigned char> serializeScriptObject (const ScriptObjectReference& reference, bool forwardUserDataOwnership = false) ;
281  ScriptObjectReference deserializeScriptObject (const std::vector<unsigned char>& object) ;
282  } ;
283 }
284 
nkScripts::Environment::setName
void setName(const char *name)
nkScripts::Environment::getVar
double getVar(const char *name, double defaultValue)
nkScripts::Environment::Environment
Environment()
nkScripts::Environment
Defines an environment in which scripts can execute.
Definition: Environment.h:14
nkScripts
Encompasses all API of component NilkinsScripts.
Definition: Environment.h:7
nkScripts::Environment::getVar
int getVar(const char *name, int defaultValue)
nkScripts::Namespace
Holds information and allow control over a namespace in a scripting environment.
Definition: Namespace.h:12
nkScripts::Environment::getFunc
Function * getFunc(const char *name)
nkScripts::Environment::setVar
void setVar(const char *name, const char *value)
nkScripts::Environment::getUserType
UserType * getUserType(const char *name)
nkScripts::Script
Holds all information for a script.
Definition: Script.h:14
nkScripts::Environment::isNamespaceSet
bool isNamespaceSet(const char *name)
nkScripts::Environment::setEnvironmentFor
void setEnvironmentFor(INTERPRETER interpretType)
nkScripts::Environment::serializeScriptObject
std::vector< unsigned char > serializeScriptObject(const ScriptObjectReference &reference, bool forwardUserDataOwnership=false)
nkScripts::Environment::setVar
void setVar(const char *name, double value)
nkScripts::Environment::getScriptFunction
ScriptObjectReference getScriptFunction(const char *name)
nkScripts::Environment::setVar
void setVar(const char *name, const ScriptObjectReference &value)
nkScripts::UserType
Represents a user type and all the information and control related.
Definition: UserType.h:27
nkScripts::DataStack
std::vector< FunctionParameter > DataStack
A data stack, mainly used for parameters.
Definition: FunctionDefines.h:8
nkScripts::Environment::setObject
void setObject(const char *name, const char *userTypeName, void *value)
nkScripts::Environment::setNamespace
Namespace * setNamespace(const char *name)
nkScripts::Environment::setVar
void setVar(const char *name, float value)
nkScripts::Environment::setUserType
UserType * setUserType(const char *name)
nkScripts::ScriptObjectReference
A reference over an object in the scripting environment.
Definition: ScriptObjectReference.h:30
nkScripts::Environment::setVar
void setVar(const char *name, bool value)
nkScripts::Environment::callScriptFunction
bool callScriptFunction(const ScriptObjectReference &reference, const DataStack &args, DataStack &expectedOutput)
nkScripts::Environment::isFuncSet
bool isFuncSet(const char *name)
nkScripts::Environment::getVar
bool getVar(const char *name, bool defaultValue)
nkScripts::Environment::isVarSet
bool isVarSet(const char *name)
nkScripts::Environment::getName
const char * getName() const
nkScripts::Environment::getNamespace
Namespace * getNamespace(const char *name)
nkScripts::Environment::deserializeScriptObject
ScriptObjectReference deserializeScriptObject(const std::vector< unsigned char > &object)
nkScripts::ExecutionResult
Holds information about the execution result of a script in an environment.
Definition: ExecutionResult.h:26
nkScripts::INTERPRETER
INTERPRETER
Supported scripting environments.
Definition: Interpreter.h:12
nkScripts::Environment::requestGarbageCollection
void requestGarbageCollection()
nkScripts::Environment::getVar
ScriptObjectReference getVar(const char *name)
nkScripts::Environment::getVar
const char * getVar(const char *name, const char *defaultValue)
nkScripts::Environment::getVar
float getVar(const char *name, float defaultValue)
nkScripts::Environment::execute
bool execute(const Script &script)
nkScripts::Environment::setFunc
Function * setFunc(const char *name)
nkScripts::Function
Holds information, and controls, over a function in a scripting environment.
Definition: Function.h:50
nkScripts::Environment::~Environment
~Environment()
nkScripts::Environment::isUserTypeSet
bool isUserTypeSet(const char *name)
nkScripts::Environment::getObject
void * getObject(const char *name, const char *userTypeName=nullptr)
nkScripts::Environment::getLastExecutionResult
const ExecutionResult & getLastExecutionResult() const
nkScripts::Environment::setVar
void setVar(const char *name, int value)